home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra / disp186b.zip / ACUMOS.ASM next >
Assembly Source File  |  1994-02-23  |  14KB  |  382 lines

  1. ;--------------------------------------------------------------------------
  2. ; This is file ACUMOS.ASM
  3. ;
  4. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  5. ; Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  6. ; Copyright (C) 1993 Hartmut Schirmer, Feldstr. 118, 2300 Kiel 1, Germany
  7. ; Copyright (C) 1993 Matthias Burian, Imhoffg. 6, 2232 Strasshof, Austria
  8. ;
  9. ; This file is distributed under the terms listed in the document
  10. ; "copying.dj", available from DJ Delorie at the address above.
  11. ; A copy of "copying.dj" should accompany this file; if not, a copy
  12. ; should be available from where this file was obtained.  This file
  13. ; may not be distributed without a verbatim copy of "copying.dj".
  14. ;
  15. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  16. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. ;--------------------------------------------------------------------------
  18. ;
  19. ; This is the graphics driver for AcuMos AVGA2 chipsets
  20. ; It has been derived from Hartmut Schirmers CIRRUS54.GRN
  21. ; and the STDVGA.GRN graphics driver by Csaba Biegl/DJ Delorie
  22. ;
  23.     .386
  24. include grdriver.inc
  25. cseg    segment use16 byte public 'code'
  26.     assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  27.  
  28.  
  29. ;--------------------------------------------------------------------------
  30. ; DRIVER HEADER
  31. ;  The following entries MUST match the structure and constant
  32. ;  declarations in the file 'grdriver.h' of the GRX graphics library
  33. ;  The mode word should contain the following bitfields:
  34. ;     - the GRD_NEW_DRIVER bit set for any new format driver
  35. ;     - the adapter type field should be specified
  36. ;     - the memory size field should be specified
  37. ;     - the paging mode field should be specified
  38. ;  The mode set routine will OR in the plane bitfield as it will
  39. ;  change when different color number modes are requested.
  40. ;--------------------------------------------------------------------------
  41.  
  42.     dw      offset mode_set_routine
  43.     dw      offset paging_routine
  44. mode_W  dw      GRD_NEW_DRIVER+GRD_VGA+GRD_1024K+GRD_NO_RW
  45. ;
  46. ; The 'def_xx' fields are filled in by go32 from the corresponding
  47. ; fields of the 'GO32' environment variable
  48. ;
  49. def_tw  dw      80              ; text width
  50. def_th  dw      25              ; text height
  51. def_gw  dw      640             ; graphics width
  52. def_gh  dw      480             ; graphics height
  53. def_nc  dw      16              ; graphics colors
  54.     dw      offset driver_init_routine
  55.     dw      offset text_mode_table
  56.     dw      offset graphics_mode_table
  57.  
  58. ;
  59. ; Biggest text and graphics sizes
  60. ;
  61. Max_TW  equ     132
  62. Max_TH  equ     50
  63. Max_GWn equ     800             ; non interlaced!!!
  64. Max_GHn equ     600
  65. Max_GW  equ     1024            ; may be interlaced
  66. Max_GH  equ     768
  67.  
  68.  
  69. ;--------------------------------------------------------------------------
  70. ; TABLE OF SUPPORTED TEXT MODES
  71. ;       - keep sorted by size
  72. ;       - end with an all 0 entry
  73. ;       - BIOS field = 0xff disables it
  74. ;       - fields:
  75. ;               width,  height, colors, BIOS#+  setup_procedure_index*256
  76. ;--------------------------------------------------------------------------
  77. text_mode_table         label word
  78.     dw      80,     25,     2,      007h +  00000h
  79.     dw      40,     25,     16,     001h +  00000h
  80.     dw      80,     25,     16,     003h +  00000h
  81.     dw      80,     50,     16,     003h +  00100h
  82.     dw      132,    25,     16,     055h +  00000h
  83.     dw      132,    43,     16,     054h +  00000h
  84.     dw      0,      0,      0,      000h +  00000h
  85.  
  86.  
  87. ;--------------------------------------------------------------------------
  88. ; TABLE OF SUPPORTED GRAPHICS MODES
  89. ;       - keep sorted first by colors then by size
  90. ;       - end with an all 0 entry
  91. ;       - BIOS field = 0xff disables it
  92. ;       - fields:
  93. ;               width,  height, colors, BIOS#+  setup_procedure_index*256
  94. ;--------------------------------------------------------------------------
  95. graphics_mode_table     label word
  96.     dw      320,    200,    16,     00dh +  00000h
  97.     dw      640,    200,    16,     00eh +  00000h
  98.     dw      640,    350,    16,     010h +  00000h
  99.     dw      640,    480,    16,     012h +  00000h
  100.     dw      800,    600,    16,     058h +  00000h
  101.     dw      1024,   768,    16,     05dh +  00000h
  102.     dw      320,    200,    256,    013h +  00000h
  103.     dw      640,    480,    256,    05fh +  00000h
  104.     dw      800,    600,    256,    05ch +  00000h
  105.     dw      0,        0,      0,    000h +  00000h
  106.  
  107. ; The AcuMos AVGA2 SVGA card supports two 'native' VESA modes,
  108. ; 640x480x256 colors. They can be accessed by the 'standard extended' modes,
  109. ; so I omitted VESA support
  110. ;
  111. ;--------------------------------------------------------------------------
  112. ; TABLE OF SPECIAL SETUP PROCEDURES
  113. ;  You may need such procedures for:
  114. ;     -- reloading fonts on standard EGA or VGA for
  115. ;        higher resolution text modes
  116. ;     -- enable HiColor mode of some Super VGAs
  117. ;     -- Handle the parameter passing conventions of the VESA BIOS
  118. ;     -- put VGA into 256 color plane mode ("MODE X")
  119. ;     -- etc...
  120. ;  There should be one entry in the table for every non-zero
  121. ;  'setup_procedure_index' in the text and graphics mode tables.
  122. ;  The first entry in the table belongs to index 100h, and so on.
  123. ;  The special setup procedure is invoked via a near call.
  124. ;
  125. ;  Entry: DI=address of the mode record from the text or graphics
  126. ;         table to set up.
  127. ;
  128. ;  Exit:  Adapter configured
  129. ;         BX=driver mode word as it should be returned by the mode set
  130. ;            routine. Typically it involves picking up the mode word
  131. ;            from the header and OR-ing in the appropriate bitplane mode
  132. ;            bitfield. (This is not needed for text modes)
  133. ;         AX, CX, DX, SI can be trashed, PRESERVE DI!!!!
  134. ;
  135. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  136. ;--------------------------------------------------------------------------
  137. special_setup_table     label word
  138.     dw      offset  VGA_50row_mode_set
  139.  
  140. ;
  141. ; Routine to set up VGA 50 row mode
  142. ; interface is described above
  143. ;
  144. VGA_50row_mode_set      proc    near
  145.     mov     ax,03h                  ; set 80x25 mode
  146.     int     10h
  147.     xor     bx,bx
  148.     mov     ax,1112h                ; load 8x8 font
  149.     int     10h
  150.     ret
  151. VGA_50row_mode_set      endp
  152.  
  153.  
  154. ;--------------------------------------------------------------------------
  155. ; DRIVER INIT ROUTINE
  156. ;  called once after the driver is loaded
  157. ;  may do one or more of the followings:
  158. ;    - check for proper board type
  159. ;    - check amount of RAM on board, and:
  160. ;       -- update word in header to reflect correct amount
  161. ;       -- disable modes in the tables for which there is not enough RAM
  162. ;    - check for special equipment (HiColor DAC, etc...)
  163. ;
  164. ;  Entry: nothing
  165. ;
  166. ;  Exit:  AX=status:
  167. ;          non-zero: OK,
  168. ;          0: something went wrong (e.g. wrong adapter, etc..)
  169. ;         BX,CX,DX may be trashed
  170. ;
  171. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  172. ;--------------------------------------------------------------------------
  173. driver_init_routine     proc    far
  174.     mov     ax,1                    ; Really primitive, but works
  175.     ret                             ; Make sure you've an GD542X Chip !
  176. driver_init_routine     endp
  177.  
  178.  
  179. ;--------------------------------------------------------------------------
  180. ; MODE SET ROUTINE
  181. ;  sets up a text or graphics mode as close as possible to the one
  182. ;  reguested by the user with regard to number of colors and size.
  183. ;
  184. ;  Entry: AX=mode selection
  185. ;     0 = 80x25 text
  186. ;     1 = default text
  187. ;     2 = text CX cols by DX rows
  188. ;     3 = biggest text
  189. ;     4 = 320x200 graphics
  190. ;     5 = default graphics
  191. ;     6 = graphics CX width by DX height
  192. ;     7 = biggest non-interlaced graphics
  193. ;     8 = biggest graphics
  194. ;     9 = graphics BX colors, CX width by DX height
  195. ;
  196. ;  Exit: BX=driver mode flag
  197. ;        CX=width (in pixels or characters)
  198. ;        DX=height
  199. ;
  200. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  201. ;        YOU SHOULD NOT NEED TO CHANGE THIS ROUTINE AS IT IS PRETTY
  202. ;        MUCH TABLE DRIVEN
  203. ;--------------------------------------------------------------------------
  204. mode_set_routine        proc    far
  205.     push    ds
  206.     push    di
  207.     push    si
  208.     mov     si,cs
  209.     mov     ds,si
  210.     cmp     ax,9
  211.     jbe     DoIt
  212.     jmp     Exit
  213. DoIt:   add     ax,ax
  214.     mov     si,ax
  215.     jmp     WORD PTR mode_set_table[si]
  216. mode_set_table  label   word
  217.     dw      offset mode_0
  218.     dw      offset mode_1
  219.     dw      offset mode_2
  220.     dw      offset mode_3
  221.     dw      offset mode_4
  222.     dw      offset mode_5
  223.     dw      offset mode_6
  224.     dw      offset mode_7
  225.     dw      offset mode_8
  226.     dw      offset mode_9
  227. mode_0: mov     si,offset text_mode_table       ; 80x25 text
  228.     mov     bx,def_nc
  229.     mov     cx,80
  230.     mov     dx,25
  231.     jmp     Lookup
  232. mode_1: mov     si,offset text_mode_table       ; default text
  233.     mov     bx,def_nc
  234.     mov     cx,def_tw
  235.     mov     dx,def_th
  236.     jmp     Lookup
  237. mode_2: mov     si,offset text_mode_table       ; CX*DX text
  238.     mov     bx,def_nc
  239.     jmp     Lookup
  240. mode_3: mov     si,offset text_mode_table       ; biggest text
  241.     mov     bx,def_nc
  242.     mov     cx,Max_TW
  243.     mov     dx,Max_TH
  244.     jmp     Lookup
  245. mode_4: mov     si,offset graphics_mode_table   ; 320x200 graphics
  246.     mov     bx,def_nc
  247.     mov     cx,320
  248.     mov     dx,200
  249.     jmp     Lookup
  250. mode_5: mov     si,offset graphics_mode_table   ; default graphics
  251.     mov     bx,def_nc
  252.     mov     cx,def_gw
  253.     mov     dx,def_gh
  254.     jmp     Lookup
  255. mode_6: mov     si,offset graphics_mode_table   ; CX*DX graphics
  256.     mov     bx,def_nc
  257.     jmp     Lookup
  258. mode_7: mov     si,offset graphics_mode_table   ; biggest non-interlaced gr
  259.     mov     bx,def_nc
  260.     mov     cx,Max_GWn
  261.     mov     dx,Max_GHn
  262.     jmp     Lookup
  263. mode_8: mov     si,offset graphics_mode_table   ; biggest graphics
  264.     mov     bx,def_nc
  265.     mov     cx,Max_GW
  266.     mov     dx,Max_GH
  267.     jmp     Lookup
  268. mode_9: mov     si,offset graphics_mode_table   ; CX*DX graphics w/ BX colors
  269. ;
  270. ; At this point:
  271. ;   SI points to the table to search (text or graphics)
  272. ;   BX has colors
  273. ;   CX has width
  274. ;   DX has height
  275. ;
  276. Lookup: xor     ax,ax                           ; last color number seen
  277. Find_C: cmp     [si+4],ax                       ; last color number == this?
  278.     je      Same_C
  279.     jb      Prev_C                          ; end of table -- use last color
  280.     cmp     BYTE PTR [si+6],0ffh            ; valid entry ?
  281.     je      Prev_C                          ; not -- use last color
  282.     mov     ax,[si+4]                       ; record color number
  283.     mov     di,si                           ; start of entries w/ this color
  284.     cmp     ax,bx                           ; enough colors ?
  285.     jae     Find_S
  286. Same_C: add     si,8
  287.     jmp     Find_C
  288. Prev_C: or      ax,ax                           ; found any color at all?
  289.     je      Exit
  290. ;
  291. ; At this point:
  292. ;   DI points into the table to the first entry with the desired color
  293. ;      number (either it has enough colors or it is the highest color
  294. ;      number supported by the driver). Additionally, at least the
  295. ;      first (= smallest size) entry for this color is valid (has a
  296. ;      valid BIOS number).
  297. ;   AX has the color number adjusted for the driver
  298. ;   CX has width
  299. ;   DX has height
  300. ;
  301. Find_S: cmp     [di+4],ax                       ; still the same color #?
  302.     jne     Prev_S
  303.     cmp     BYTE PTR [di+6],0ffh            ; valid entry ?
  304.     je      Prev_S
  305.     cmp     [di],cx
  306.     jb      Next_S
  307.     cmp     [di+2],dx
  308.     jae     GotIt
  309. Next_S: add     di,8
  310.     jmp     Find_S
  311. Prev_S: sub     di,8
  312. ;
  313. ; At this point:
  314. ;   DI points to the table entry we want to set up
  315. ;
  316. GotIt:  mov     ax,[di+6]                       ; BIOS mode number
  317.     or      ah,ah                           ; special ?
  318.     je      doBIOS
  319.     mov     al,ah
  320.     xor     ah,ah
  321.     dec     ax
  322.     add     ax,ax
  323.     mov     si,ax
  324.     call    WORD PTR special_setup_table[si]
  325.     jmp     RetVal
  326. doBIOS: int     10h
  327.     mov     bx,GRD_1_PLANE
  328.     cmp     WORD PTR [di+4],2               ; 2 colors ?
  329.     je      doFLAG
  330.     mov     bx,GRD_4_PLANES
  331.     cmp     WORD PTR [di+4],16              ; 16 colors ?
  332.     je      doFLAG
  333.     mov     bx,GRD_8_PLANES
  334.     cmp     WORD PTR [di+4],256             ; 256 colors ?
  335.     je      doFLAG
  336.     mov     bx,GRD_16_PLANES
  337.     cmp     WORD PTR [di+4],32768           ; 32K colors ?
  338.     je      doFLAG
  339.     mov     bx,GRD_PLANE_MASK               ; something is wrong!!
  340. doFLAG: or      bx,mode_W
  341. RetVal: mov     cx,[di]
  342.     mov     dx,[di+2]
  343. Exit:   pop     si
  344.     pop     di
  345.     pop     ds
  346.     ret
  347. mode_set_routine        endp
  348.  
  349.  
  350. ;--------------------------------------------------------------------------
  351. ; PAGING ROUTINE
  352. ;
  353. ;  Entry: AH=read page
  354. ;         AL=write page
  355. ;
  356. ;  Exit: VGA configured.
  357. ;        AX,BX,CX,DX,SI,DI may be trashed
  358. ;
  359. ;  NOTE: This runs in protected mode!  Don't mess with the segment registers!
  360. ;        This code must be relocatable and may not reference any data!
  361. ;--------------------------------------------------------------------------
  362.     assume  ds:nothing, es:nothing
  363.  
  364. paging_routine  proc    far
  365.     shl     ah,4
  366.     mov     dx,03ceh
  367.     mov     al,9
  368.     out     dx,al
  369.     inc     dx
  370.     mov     al,ah
  371.     out     dx,al
  372.  
  373.     mov     al,8            ; reconfig GR CTRL port for mask writes
  374.     dec     dx
  375.     out     dx,al
  376.     ret
  377. paging_routine  endp
  378.  
  379.  
  380. cseg    ends
  381.     end
  382.